<style>
  .box a {
    width: 200px;
    display: inline-block;
  }
</style>

<body>
  <div>
    <input class="i1" type="number" style="width: 200px;" placeholder="输入打目录页数">
    <input type="button" value="打开目录" class="btn" onclick="openPage(1)">
  </div>
  <div>
    <input class="i2" type="number" style="width: 200px;" placeholder="输入打开设置的个数">
    <input type="button" value="打开设置" class="btn" onclick="openPage(2)">
  </div>
  <div>
    <input class="i3" type="number" style="width: 200px;" placeholder="输入打开回收站的个数">
    <input type="button" value="打开回收站" class="btn" onclick="openPage(3)">
  </div>
  <input class="begin" type="number" style="width: 200px;" placeholder="开始页面">
</body>
<!-- (div.box>a[href=https://www.yuque.com/__backup__/a$ target="_blank"]{备用a$}a[href=https://www.yuque.com/__backup__/a$/toc target="_blank"]{备用a$设置})*100 -->

<script>
  // https://www.yuque.com/dashboard/recycles 语雀可回收站
  let repository = [
    { title: "HTML CSS", url: "web" },
    { title: "Javascript", url: "js" },
    { title: "前端框架", url: "web2" },
    { title: "Dart", url: "dart" },
    { title: "Kotlin", url: "kotlin" },
    { title: "Swift", url: "swift" },
    { title: "c#", url: "csharp" },
    { title: "C语言", url: "cc" },
    { title: "C++", url: "cpp" },
    { title: "golang", url: "go" },
    { title: "Java", url: "java" },
    { title: "Python", url: "python" },
    { title: "PHP", url: "php" },
    { title: "Node", url: "node" },
    { title: "Shell", url: "shell" },
    { title: "Linux操作系统", url: "linux" },
    { title: "容器和集群", url: "devops" },
    { title: "编程开发", url: "dev" },
    { title: "程序设计模式", url: "mode" },
    { title: "效率办公", url: "fast" },
    { title: "产品经理", url: "pm" },
    { title: "中转站", url: "swap" },
  ]
  window.repository = repository
  console.log("知识库存有：", repository)
  repository.forEach((item, i) => {
    if (i == 0) {
      let d = document.createElement("div");
      d.innerText = repository.length + "个页面"
      document.body.appendChild(d);
    }
    let divBox = document.createElement("div");
    divBox.className = "box";
    let a1 = document.createElement("a");
    let a2 = document.createElement("a");
    let a3 = document.createElement("a");
    a1.target = "_blank"
    a2.target = "_blank"
    a3.target = "_blank"
    a1.innerText = `${item.title} 目录`
    a1.href = `https://www.yuque.com/kenguba/${item.url}`

    a2.innerText = `${item.title} 设置`
    a2.href = `https://www.yuque.com/kenguba/${item.url}/settings/advanced`
    // a2.href = `https://www.yuque.com/r/kenguba/${item.url}/statistics`

    a3.innerText = `${item.title} 回收站`
    // a3.href = `https://www.yuque.com/r/kenguba/${item.url}/docs?q=&show_by=&sort_by=&status=notInTOC&type=&user_ids=`
    a3.href = `https://www.yuque.com/r/kenguba/${item.url}/trash`

    divBox.appendChild(a1);
    divBox.appendChild(a2);
    divBox.appendChild(a3);
    document.body.appendChild(divBox);
  })


  Array(30).fill().forEach((item, i) => {
    if (i == 0) {
      let d = document.createElement("div");
      d.innerText = repository.length
      document.body.appendChild(d);
    }
    let divBox = document.createElement("div");
    divBox.className = "box";
    let a1 = document.createElement("a");
    let a2 = document.createElement("a");
    a1.target = "_blank"
    a2.target = "_blank"
    a1.href = `https://www.yuque.com/kenguba/a${i + 1}`
    // a2.href = `https://www.yuque.com/kenguba/a${i + 1}/toc/`
    a2.href = `https://www.yuque.com/kenguba/a${i + 1}/toc/`
    a1.innerText = `b${i + 1}`
    a2.innerText = `b${i + 1}设置`
    divBox.appendChild(a1);
    divBox.appendChild(a2);
    document.body.appendChild(divBox);
  })

  function openPage(nodeNum = 1) {
    let num = document.querySelector(`.i${nodeNum}`).value || 1;
    let a1 = document.querySelectorAll(`.box a:nth-child(${nodeNum})`)
    if (parseInt(num) > a1.length) return alert("大于节点")
    var begin = document.querySelector(`.begin`).value - 1 || 1;
    for (let i = begin; i < num; i++) {
      setTimeout(() => { a1[i].click() }, 800 * i);
    }
  }
</script>


